{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c3dc594c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "        ts_code trade_date      close       open       high        low  \\\n",
      "0     000300.SH   20220930  3804.8853  3833.3504  3848.6018  3801.2798   \n",
      "1     000300.SH   20220929  3827.1434  3864.3160  3873.1823  3808.6496   \n",
      "2     000300.SH   20220928  3828.7098  3879.4398  3879.4398  3828.0545   \n",
      "3     000300.SH   20220927  3892.2950  3844.0692  3893.0283  3827.9265   \n",
      "4     000300.SH   20220926  3836.6773  3829.5958  3893.3186  3827.9498   \n",
      "...         ...        ...        ...        ...        ...        ...   \n",
      "4309  000300.SH   20050110   993.8790   983.7600   993.9590   979.7890   \n",
      "4310  000300.SH   20050107   983.9580   983.0450   995.7110   979.8120   \n",
      "4311  000300.SH   20050106   983.1740   993.3310   993.7880   980.3300   \n",
      "4312  000300.SH   20050105   992.5640   981.5770   997.3230   979.8770   \n",
      "4313  000300.SH   20050104   982.7940   994.7690   994.7690   980.6580   \n",
      "\n",
      "      pre_close   change  pct_chg           vol        amount  \n",
      "0     3827.1434 -22.2581  -0.5816  7.855997e+07  1.586927e+08  \n",
      "1     3828.7098  -1.5664  -0.0409  8.565414e+07  1.716359e+08  \n",
      "2     3892.2950 -63.5852  -1.6336  8.659221e+07  1.724380e+08  \n",
      "3     3836.6773  55.6177   1.4496  8.886016e+07  1.859552e+08  \n",
      "4     3856.0212 -19.3439  -0.5017  1.045260e+08  1.929062e+08  \n",
      "...         ...      ...      ...           ...           ...  \n",
      "4309   983.9580   9.9210   1.0083  5.791698e+06  3.762933e+06  \n",
      "4310   983.1740   0.7840   0.0797  7.298694e+06  4.737469e+06  \n",
      "4311   992.5640  -9.3900  -0.9460  6.288029e+06  3.921015e+06  \n",
      "4312   982.7940   9.7700   0.9941  7.119109e+06  4.529208e+06  \n",
      "4313  1000.0000 -17.2060  -1.7206  7.412869e+06  4.431977e+06  \n",
      "\n",
      "[4314 rows x 11 columns]\n"
     ]
    }
   ],
   "source": [
    "# pip install tushare\n",
    "\n",
    "# 导入tushare\n",
    "import tushare as ts\n",
    "# 初始化pro接口\n",
    "pro = ts.pro_api('854634d420c0b6aea2907030279da881519909692cf56e6f35c4718c')\n",
    "\n",
    "# 拉取数据\n",
    "df = pro.index_daily(**{\n",
    "    \"ts_code\": \"000300.SH\",\n",
    "    \"trade_date\": \"\",\n",
    "    \"start_date\": \"\",\n",
    "    \"end_date\": \"\",\n",
    "    \"limit\": \"\",\n",
    "    \"offset\": \"\"\n",
    "}, fields=[\n",
    "    \"ts_code\",\n",
    "    \"trade_date\",\n",
    "    \"close\",\n",
    "    \"open\",\n",
    "    \"high\",\n",
    "    \"low\",\n",
    "    \"pre_close\",\n",
    "    \"change\",\n",
    "    \"pct_chg\",\n",
    "    \"vol\",\n",
    "    \"amount\"\n",
    "])\n",
    "print(df)\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6130e9ce",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
